package com.zretc.kscxmz.controller.tongxunlu;


import com.github.pagehelper.PageInfo;
import com.zretc.kscxmz.entity.tongxunlu.Sex;
import com.zretc.kscxmz.entity.tongxunlu.TongXun;
import com.zretc.kscxmz.services.TongXunluService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("tongxun")
public class TongXunluController {
    private static final Logger logger = LoggerFactory.getLogger(TongXunluController.class);
    @Autowired
    private TongXunluService tongXunluService;


    /*根据字母列表查询出来姓*/
    @RequestMapping("select")
    @ResponseBody
    public Sex findAlist(Sex ziMu, Model model) {
        Sex alist = tongXunluService.findAlist(ziMu);
        model.addAttribute("data", alist);
        return alist;
    }

    /*根据姓 查询 */
    @RequestMapping("list")
    @ResponseBody
    public PageInfo<TongXun> findlist(String xing,
                                      @RequestParam(value = "pageNum") int pageNum,
                                      @RequestParam(value = "pageSize") int pageSize) {
        PageInfo<TongXun> tongXuns = tongXunluService.find(xing, pageNum, pageSize);
        return tongXuns;

    }


    /*字母表查询所有*/
    @RequestMapping("findlist")
    @ResponseBody
    public PageInfo<TongXun> findlist(
            @RequestParam(value = "pageNum") int pageNum,
            @RequestParam(value = "pageSize") int pageSize) {

        PageInfo<TongXun> tongXuns = tongXunluService.list(pageNum, pageSize);
        return tongXuns;
    }

/**/

    /*根据其他模糊查询*/
    @RequestMapping("allfind")
    @ResponseBody
    public PageInfo<TongXun> allfind(TongXun tongXun,
                                        @RequestParam(value = "pageNum") int pageNum,
                                        @RequestParam(value = "pageSize") int pageSize) {
        PageInfo<TongXun> tongXuns = tongXunluService.allfind(tongXun,pageNum, pageSize);
        return tongXuns;
    }
    /*住址*/
}
